<?php
/**
 * 
 * @author Natanael
 * Modelo de IB_SetupMessages
 * 
 */

class MSetupMessages extends Model
{
	
	private $_nameTable = "IB_SetupMessages";
	
    public function __construct()
	{
	    parent::Model();
	    $this->load->database();
	}
	
    public function loadObjeto($start = false, $offset = false, $sortname = false, $sortorder = false)
    {
          if($offset != false)
		       $this->db->limit($offset, $start);

		   if($sortname != false && $sortorder != false) 
			    $this->db->order_by($sortname, $sortorder);
				  
		    $result = $this->db->get_where($this->_nameTable);
	
			return $this->GetArrayFromQueryResult($result);
			
     }
     
    public function LoadObjetoById($id) 
	{
		  $qresult = $this->db->get_where($this->_nameTable, array('Id' => $id));		
		
		  if ($qresult->num_rows() == 0)
		  {
			return false;
		  }	
           
		  return new IbSetupMessages($qresult->row());
	}
	
    public function LoadObjetoByArray($where) 
	{
		  $qresult = $this->db->get_where($this->_nameTable, $where);		
		
		  if ($qresult->num_rows() == 0)
		  {
			return false;
		  }	
           
		  return new IbSetupMessages($qresult->row());
	}
     
    public function GetArrayFromQueryResult($result) 
	{
			if ($result->num_rows() == 0)
				return false;
	
			$query_arr = array();
	
			foreach ($result->result() as $record) {
				$query_arr[] = new IbSetupMessages($record);
		    }
	
			return $query_arr;
     }
     
     public function addReguistro($data)
     {
          if($this->db->insert($this->_nameTable,$data)){
           	  return true;
          }
           
           return false;
      }
      
      public function editReguistro($data, $id)
      {
           if ($this->db->update($this->_nameTable,$data,array('Id'=>$id))) {
           	  return true;
           }
           
            return false;
       }
       
      public function deleteReguistro($id)
      {
           if ($this->db->delete($this->_nameTable,array('Id'=>$id))) {
           	  return true;
           }
           
            return false;
       }
	
}

class IbSetupMessages
{
	  private $_id = 0;
      private $_idService = 0;
      private $_idScript = 0;
      private $_type = "";
      
      public function __construct($objeto)
      {
      	 $this->setId($objeto->Id);
         $this->setIdService($objeto->Id_Service);
         $this->setIdScript($objeto->Id_Script);
         $this->setType($objeto->Type);
      }
      
      public function getId()
      {
         return $this->_id;
      }
      
      public function setId($value)
      {
         $this->_id = $value;
      }
      
      public function getIdService()
      {
         return $this->_idService;
      }
      
      public function setIdService($value)
      {
         $this->_idService = $value;
      }
      
      public function getIdScript()
      {
         return $this->_idScript;
      }
      
      public function setIdScript($value)
      {
         $this->_idScript = $value;
      }
      
      public function getType()
      {
         return $this->_type;
      }
      
      public function setType($value)
      {
         $this->_type = $value;
      }

}